using Unity.Entities;
using UnityEngine;

namespace Kickball.Execute
{
    public struct ObstacleSpawner : IComponentData
    {
    }
    
    public struct PlayerSpawner : IComponentData
    {
    }

    public struct PlayerMovement : IComponentData
    {
    }

    public struct BallSpawner : IComponentData
    {
    }

    public struct BallMovement : IComponentData
    {
    }

    public struct PlayerMovement_Job : IComponentData
    {
    }
    
    public struct BallMovement_Job : IComponentData
    {
    }

    public struct BallCarry : IComponentData
    {
    }

    public struct BallKicking : IComponentData
    {
    }

    public class ExecuteAuthoring : MonoBehaviour
    {
        [Header("Step 1 生成障碍物")] 
        public bool ObstacleSpawner;
        
        [Header("Step 2 生成球员")] 
        public bool PlayerSpawner;
        
        [Header("Step 2 球员移动")] 
        public bool PlayerMovement;
        
        [Header("Step 3 生成球（小键盘 Enter 键）")] 
        public bool BallSpawner;
        
        [Header("Step 3 球移动")] 
        public bool BallMovement;
        
        [Header("Step 4 球员移动（Job）")] 
        public bool PlayerMovement_Job;
        
        [Header("Step 4 球移动（Job）")] 
        public bool BallMovement_Job;
        
        [Header("Step 5 球携带（键盘 C 键）")] 
        public bool BallCarry;
        
        [Header("Step 5 踢球（键盘 Space 键）")] 
        public bool BallKicking;

        class Baker : Baker<ExecuteAuthoring>
        {
            public override void Bake(ExecuteAuthoring authoring)
            {
                var entity = GetEntity(TransformUsageFlags.None);
                if (authoring.ObstacleSpawner) AddComponent(entity, new ObstacleSpawner());
                if (authoring.PlayerSpawner) AddComponent(entity, new PlayerSpawner());
                if (authoring.PlayerMovement) AddComponent(entity, new PlayerMovement());
                if (authoring.BallSpawner) AddComponent(entity, new BallSpawner());
                if (authoring.BallMovement) AddComponent(entity, new BallMovement());
                if (authoring.PlayerMovement_Job) AddComponent(entity, new PlayerMovement_Job());
                if (authoring.BallMovement_Job) AddComponent(entity, new BallMovement_Job());
                if (authoring.BallCarry) AddComponent(entity, new BallCarry());
                if (authoring.BallKicking) AddComponent(entity, new BallKicking());
            }
        }
    }
}